/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "submenu")
@NamedQueries({
    @NamedQuery(name = "Submenu.findAll", query = "SELECT s FROM Submenu s"),
    @NamedQuery(name = "Submenu.findByMenuId", query = "SELECT s FROM Submenu s WHERE s.submenuPK.menuId = :menuId"),
    @NamedQuery(name = "Submenu.findBySubmenuId", query = "SELECT s FROM Submenu s WHERE s.submenuPK.submenuId = :submenuId"),
    @NamedQuery(name = "Submenu.findByMenuIdBySubmenuId", query = "SELECT s FROM Submenu s WHERE s.submenuPK.menuId = :menuId AND s.submenuPK.submenuId = :submenuId"),
    @NamedQuery(name = "Submenu.findByName", query = "SELECT s FROM Submenu s WHERE s.name = :name"),
    @NamedQuery(name = "Submenu.findByUrl", query = "SELECT s FROM Submenu s WHERE s.url = :url"),
    @NamedQuery(name = "Submenu.findByOrder", query = "SELECT s FROM Submenu s WHERE s.order = :order")})
public class Submenu implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SubmenuPK submenuPK;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @Column(name = "url")
    private String url;
    @Basic(optional = false)
    @Column(name = "order")
    private short order;
    @JoinColumn(name = "menuId", referencedColumnName = "menuId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Menu menu;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "submenu")
    private Collection<Option> optionCollection;

    public Submenu() {
    }

    public Submenu(SubmenuPK submenuPK) {
        this.submenuPK = submenuPK;
    }

    public Submenu(SubmenuPK submenuPK, String name, String url, short order) {
        this.submenuPK = submenuPK;
        this.name = name;
        this.url = url;
        this.order = order;
    }

    public Submenu(short menuId, short submenuId) {
        this.submenuPK = new SubmenuPK(menuId, submenuId);
    }

    public SubmenuPK getSubmenuPK() {
        return submenuPK;
    }

    public void setSubmenuPK(SubmenuPK submenuPK) {
        this.submenuPK = submenuPK;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public short getOrder() {
        return order;
    }

    public void setOrder(short order) {
        this.order = order;
    }

    public Menu getMenu() {
        return menu;
    }

    public void setMenu(Menu menu) {
        this.menu = menu;
    }

    public Collection<Option> getOptionCollection() {
        return optionCollection;
    }

    public void setOptionCollection(Collection<Option> optionCollection) {
        this.optionCollection = optionCollection;
    }
/*
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (submenuPK != null ? submenuPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Submenu)) {
            return false;
        }
        Submenu other = (Submenu) object;
        if ((this.submenuPK == null && other.submenuPK != null) || (this.submenuPK != null && !this.submenuPK.equals(other.submenuPK))) {
            return false;
        }
        return true;
    }

    @Override	*/
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Submenu[ submenuPK=" + submenuPK + " ]";
    }
    
}
